package ca.qc.bdeb.jeuxdesboites.commun;

import ca.qc.bdeb.utilitaires.Direction;

/**
 * 
 * @author Eric Wenaas <eric.wenaas@bdeb.qc.ca>
 * @version 0.3
 */
public class Coup {
    public final int positionX;
    public final int positionY;
    public final Direction direction;
    
    public Coup(int x, int y, Direction d) {
	positionX = x;
	positionY = y;
	direction = d;
    } 

    @Override
    public boolean equals(Object o) {
	boolean reponse = false;
	
	if (o instanceof Coup) {
	    Coup autreCoup = (Coup) o;
	    if (autreCoup.positionX == positionX && 
		autreCoup.positionY == positionY &&
		autreCoup.direction == direction) {
		reponse = true;
	    }
	}
	return reponse;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 67 * hash + this.positionX;
        hash = 67 * hash + this.positionY;
        hash = 67 * hash + (this.direction != null ? this.direction.hashCode() : 0);
        return hash;
    }
    
    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("X: ");
        builder.append(positionX);
        builder.append(" Y: ");
        builder.append(positionY);
        builder.append(" Direction: ");
        builder.append(direction.toString());
        return builder.toString();
    }
}
